package com.ruoyi.system.service.impl;

import java.util.HashMap;
import java.util.List;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.Analyse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.AgentMapper;
import com.ruoyi.system.domain.Agent;
import com.ruoyi.system.service.IAgentService;
import com.ruoyi.common.core.text.Convert;

/**
 * 中介Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-03-14
 */
@Service
public class AgentServiceImpl implements IAgentService 
{
    @Autowired
    private AgentMapper agentMapper;

    /**
     * 查询中介
     * 
     * @param id 中介ID
     * @return 中介
     */
    @Override
    public Agent selectAgentById(Long id)
    {
        return agentMapper.selectAgentById(id);
    }

    /**
     * 查询中介列表
     * 
     * @param agent 中介
     * @return 中介
     */
    @Override
    @DataScope(deptAlias = "a", userAlias = "a")
    public List<Agent> selectAgentList(Agent agent)
    {
        return agentMapper.selectAgentList(agent);
    }

    @Override
    public List<Agent> selectAgents(Agent agent)
    {
        return agentMapper.selectAgents(agent);
    }

    @Override
    public List<Agent> selectGuestList(Agent agent)
    {
        return agentMapper.selectGuestList(agent);
    }

    /**
     * 查询统计分析
     *
     */
    @Override
    @DataScope(deptAlias = "u", userAlias = "u")
    public List<Analyse> selectAnalysizeList(Analyse analyse)
    {
        return agentMapper.selectAnalysizeList(analyse);
    }

    /**
     * 新增中介
     * 
     * @param agent 中介
     * @return 结果
     */
    @Override
    public int insertAgent(Agent agent)
    {
        agent.setCreateTime(DateUtils.getNowDate());
        return agentMapper.insertAgent(agent);
    }

    /**
     * 修改中介
     * 
     * @param agent 中介
     * @return 结果
     */
    @Override
    public int updateAgent(Agent agent)
    {
        agent.setUpdateTime(DateUtils.getNowDate());
        return agentMapper.updateAgent(agent);
    }

    /**
     * 删除中介对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteAgentByIds(String ids)
    {
        return agentMapper.deleteAgentByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除中介信息
     * 
     * @param id 中介ID
     * @return 结果
     */
    @Override
    public int deleteAgentById(Long id)
    {
        return agentMapper.deleteAgentById(id);
    }
}
